//
//  LDSBaseView.m
//  LDSMVVMBase
//
//  Created by kai_leedarson on 2017/9/30.
//  Copyright © 2017年 maple_leedarson. All rights reserved.
//

#import "LDSBaseView.h"

@implementation LDSBaseView
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self viewSetup];
        [self frameSetup];
    }
    return self;
}

- (instancetype)init {
    if (self = [super init]) {
        [self viewSetup];
        [self frameSetup];
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    [self viewSetup];
    [self frameSetup];
}

- (void)viewSetup {
    
}

- (void)frameSetup {
    
}

- (void)setModel:(id)model {
    _model = model;
}
- (void)controlEvent:(UIControl *)sender {
    [self toCallBackWithTaget:self index:sender.tag model:self.model];
}

- (void)toCallBackWithIndex:(NSInteger)index
{
    [self toCallBackWithTaget:self index:index model:self.model];
}

- (void)toCallBackWithTaget:(id)taget index:(NSInteger)index model:(id)model
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(view:index:model:)]) {
        [self.delegate view:taget index:index model:model];
    }
}



@end
